#include "SDL/SDL.h"

#ifndef GENESIS_DATATYPES
#define GENESIS_DATATYPES
typedef unsigned char byte;
typedef unsigned short word;
#endif

#define PIXELSIZE 2

#define DISPLAYWIDTH (320*PIXELSIZE)
#define DISPLAYHEIGHT (224*PIXELSIZE)
#define DISPLAYSIZE (DISPLAYWIDTH*DISPLAYHEIGHT)

#define TWIDTH 64                   //
#define THEIGHT 32

#define TILEW 8
#define TILEH 8
#define TILESIZE (TILEW*TILEH)

#define FGRAMSIZE 8192
#define BGRAMSIZE 8192
#define VRAMSIZE 0xFFFF

#define PRIORITY_NONE 0
#define PRIORITY_HIGH 1
#define PRIORITY_LOW  2 

void spritesToPixelBuf(int);
void fgTilesToPixelBuf(int);
void bgTilesToPixelBuf(int);

void textToPixelBuf();
void textToPixelBuf(word *ram, long *buf, int width, int height);

void fgTile(int index, word id);
void bgTile(int index, word id);

void textTile(int index, word id);
void textTileExt(int index, word id, word *ram);
//void fgTileDraw(int screenx, int screeny, int index, int desttile, int line);
//void fgTileDrawFlipX(int screenx, int screeny, int index, int desttile, int line);
//void fgTileDrawFlipY(int screenx, int screeny, int index, int desttile, int line);
//void fgTileDrawFlipXY(int screenx, int screeny, int index, int desttile, int line);

void initVideo();

void InitTiles();    
//void DrawTiles(SDL_Surface *scr);
void KillTiles();
word *getfgRam();
word *getvRam();
void setfcRam(byte line, byte index, word color);
void setbcRam(byte line, byte index, word color);
word getfcRam(byte line, byte index);
word getbcRam(byte line, byte index);
void fgRamDraw();

void setpixel(SDL_Surface *surface, int x, int y, Uint8 r, Uint8 g, Uint8 b);
void setpixelscale(int size, SDL_Surface *surface, int x, int y, int color);
void setpixelscale(int size, SDL_Surface *surface, int x, int y, Uint8 r, Uint8 g, Uint8 b);

void vRamToSurface(SDL_Surface* surface);
void UpdateHScrollTable(long *buf);
void UpdateVScrollFullscreen(long scrollval);
void UpdateSpriteTable(byte *buf);
void writeVRAM(byte *buf, word len, word offset);

void setpixelbuf(long *buf, int x, int y, int color);
void setpixelbuf(long *buf, int x, int y, int color, bool bigpixel);
void setpixelbuf(long *buf, int x, int y, int color, int width, int height);
void setpixelbuf(long *buf, int x, int y, int color, int width, int height, bool bigpixel);

void buftosurface(long *buf, SDL_Surface *surface);
void pixelbuftosurface(SDL_Surface *surface);

void videoToSurface(SDL_Surface *surface);
void SDL_DrawRect(SDL_Surface *super, Sint16 x, Sint16 y, Uint16 w, Uint16 h, Uint32 color);
void PalLoadBG(int id);
void PalLoadFG(int id);
void setpixel(SDL_Surface *surface, int x, int y, Uint8 r, Uint8 g, Uint8 b);
void put_pixel32( SDL_Surface *surface, int x, int y, int pixel );
int get_pixel32( SDL_Surface *surface, int x, int y );

